package com.arcadia.d2.heroes;

import java.util.ArrayList;

import com.arcadia.d2.hero.Hero;
import com.arcadia.d2.hero_attributes.Armor;
import com.arcadia.d2.hero_attributes.Attribute;
import com.arcadia.d2.hero_attributes.IHeroes;
import com.arcadia.d2.hero_attributes.MagicRes;
import com.arcadia.d2.hero_attributes.attack.Attack;
import com.arcadia.d2.hero_attributes.attack.AttackSpeed;
import com.arcadia.d2.hero_attributes.skill.Ability;
import com.arcadia.d2.item_attributes.Item;

public class Earthshaker extends Hero implements IHeroes {

	private int id;
	private String name;
	private int lv;

	private Attack attack;
	private AttackSpeed attackSpeed;
	private Attribute attribute;
	private MagicRes magicRes;
	private Armor armor;
	private ArrayList<Ability> abilities = new ArrayList<Ability>();
	private Ability Fissure = new Ability(), 
					EnchantTotem = new Ability(), 
					Aftershock = new Ability(), 
					EchoSlam = new Ability();
	private Item[] itemSlot = new Item[6];
	
	
	//Constructor, no parameter, initiate everything
	public Earthshaker(){
		this.id = 0;
		this.name =  "Earth Shaker";
		this.lv = 1;
		this.itemSlot = null;
		
		this.attack = new Attack(24, 34);
		this.attackSpeed = new AttackSpeed(this.id, 0);
		this.attribute = new Attribute(22, 12, 16, 2.9, 1.4, 1.8);
		this.magicRes = new MagicRes(.25);
		this.armor = new Armor(3);
		
		this.Fissure.setMagicalDamage(275);
		this.abilities.add(Fissure);

		this.EnchantTotem.setPhysicalDamage(4*attack.getAttackDamage(this.attribute.getIStrength(this.lv)));
		this.abilities.add(EnchantTotem);
		
		this.Aftershock.setMagicalDamage(375);
		this.abilities.add(Aftershock);
		
		this.EchoSlam.setUniversalDamage(270);
		this.EchoSlam.setMagicalDamage(70);
		this.abilities.add(EchoSlam);
	}

	public int getId() {
		return this.id;
	}

	public String getName() {
		return this.name;
	}

	public Attack getAttack() {
		return this.attack;
	}

	public AttackSpeed getAttackSpeed() {
		return this.attackSpeed;
	}

	public Attribute getAttribute() {
		return this.attribute;
	}

	public MagicRes getMagicRes() {
		return this.magicRes;
	}
	
	public Armor getArmor() {
		return this.armor;
	}
	
	public ArrayList<Ability> getAbilities() {
		return this.abilities;
	}
	
	public int getLevel(){
		return lv;
	}
	
	public Item[] getItem(){
		return itemSlot;
	}
	
	public void setLevel(int lv){
		this.lv = lv;
	}
	
	public void setItem(Item[] itemSlot){
		this.itemSlot = itemSlot;
	}
	
	//IronBranch as an example. Generalize to Items later on.
	public void equip(Item[] itemSlot) {
		
		for (int i = 0 ; i < 6; i++){
			this.attack.setGreen(itemSlot[i].getAttack().getGreen());
			this.attackSpeed.setIAS(itemSlot[i].getAttackSpeed().getIAS());
			this.attribute.setIStrengthFromItem(itemSlot[i].getAttribute().getIStrengthFromItem());
			this.attribute.setIAgilityFromItem(itemSlot[i].getAttribute().getIAgilityFromItem());
			this.attribute.setIIntelligenceFromItem(itemSlot[i].getAttribute().getIIntelligenceFromItem());
			this.armor.setIArmor(itemSlot[i].getArmor().getBaseArmor(), itemSlot[i].getAttribute().getIAgilityFromItem());
			this.magicRes.setIMagicResistance(itemSlot[i].getMagicRes().getBase());
			/*crit, ability*/
		}
		
	}
	
	public String toString(){
		return this.name;
	}

}
